
define(function (require, exports) {
	/**
	 * 页面加载完成时触发
	 * @param hashCode 路由ID
	 * @param data 传递数据对象
	 * @param cite 页面站点信息
	 */
	exports.ready = function (hashCode, data, cite) {
		yufp.lookup.reg('USE_TASK_RUN_STATE,USE_JOB_RUN_STATE');
		yufp.custom.vue({
			el: cite.el,
			data: function () {
				var errorFlagOption = [{ key: 'N', value: '成功' }, { key: 'Y', value: '失败' }];
				var statusOption = [{ key: 'Running', value: '运行中' }, { key: 'Interrupting', value: '中断中' }, { key: 'Interrupted', value: '被中断' }, { key: 'S', value: '已停止' },
				{ key: 'Stopped', value: '已结束' }, { key: 'Finished', value: '已完成' }, { key: 'Debugging', value: '测试中' }, { key: 'Preparing', value: '准备中' }]
				var _this = this;
				return {
					/**历史start*/
					customKey: '',
					routeId: '',
					searchFormdataHis: {},
					/* 			appNameDisabled: false,*/
					taskNameDisabled: false,
					//treeDataUrl: "api/use/monitor/taskMonitor/queryScheduleHisTreeList",
					dataUrlHis: 'api/use/monitor/taskMonitorHis/queryList',
					/* 				flowsheetShow: false, */
					/* 	rerunShow: false, */
					/* statusOption: statusOption, */
					/* formdata: {}, */
					/* 	async: false, */
					/* param: { UNITID: '0000', LEVELUNIT: '1' }, */
					/* height: yufp.frame.size().height - 115, */
					/* errorFlagOption: errorFlagOption, */
					/* 		viewTitleArrry: ['普通事件监控'], */
					/* 		viewTitle: '', */
					/* 					isAppNode: false,
										isNodeLeaf: false, */
					/* nodeLeafData: {}, */
					/* 					currAppNode: {},
										currNodeData: {}, */
					/* mainTag: 'tasks', */
					/* historyTaskLogTag: 'historyTasksLog', */
					/* queryName: "", */
					queryStaticsFields: [
						{ placeholder: '开始日期', field: 'beginDate', type: 'date', format: "yyyyMMdd" },
						{ placeholder: '结束日期', field: 'endDate', type: 'date', format: "yyyyMMdd" },

					],
					queryStaticsButtons: [
						{
							label: '搜索', op: 'submit', type: 'primary', click: function (model, valid) {

								let startDate = "";
								let endDate = "";

								if (model.beginDate != null && model.beginDate != '') {
									startDate = _this.formartCycleDate(model.beginDate);

								}

								if (model.endDate != null && model.endDate != '') {
									endDate = _this.formartCycleDate(model.endDate);

								}

								_this.queryTaskHisInfo(startDate, endDate);

							}
						},
						{ label: '重置', op: 'reset' }
					],
					//排序字段映射
					sortColunmsHis: {
						'appName': 'APP_NAME',
						'taskName': 'TASK_NAME',
						'cycleTime': 'CYCLE_TIME',
						'errorFlag': 'ERROR_FLAG'
					},
					//排序方式映射
					sortTypesHis: {
						'descending': 'desc',
						'ascending': 'asc'
					},
					cycleTimeLabel: '周期时点',
					cycleTimeBtnLabel: '运行',
					cycleLoading: false,
					/**历史end*/
					typeone: 'task',
					tbHeight: '0',
					loading: false,//运行任务时候加载loading
					searchFormdata: {},
					cycleTitle: "",
					cycleOpr: "",
					appNameDisabled: false,
					groupNameDisabled: false,
					cycleTimeVisible: false,
					runFnButton: !yufp.session.checkCtrl('runFn'),
					debugFnButton: !yufp.session.checkCtrl('debugFn'),
					treeDataUrl: "api/use/monitor/taskMonitor/queryScheduleTreeList",
					wftRunDataUrl: "api/use/monitor/taskMonitor/queryList",
					dataUrl: 'api/use/UseTaskLogs/TakLog',
					flowsheetShow: false,
					rerunShow: false,
					statusOption: statusOption,
					formdata: {},
					async: false,
					param: { UNITID: '0000', LEVELUNIT: '1' },
					height: yufp.frame.size().height - 185,
					errorFlagOption: errorFlagOption,
					viewTitleArrry: ['普通事件监控'],
					viewTitle: '',
					isAppNode: false,
					isNodeLeaf: false,
					nodeLeafData: {},
					currAppNode: {},
					currNodeData: {},
					mainTag: 'tasks',
					historyTaskLogTag: 'historyTasksLog',
					intervalSelection: {
						key: '60000',
						label: '60秒'
					},
					refreshIntervalOptions: [{ key: '864000000', label: '不自动刷新' }, { key: '10000', label: '10秒' }, { key: '20000', label: '20秒' }, { key: '30000', label: '30秒' }, { key: '60000', label: '60秒' }],
					queryName: "",
					//排序字段映射
					sortColunms: {
						'appName': 'APP_NAME',
						'groupName': 'GROUP_NAME',
						'cyclePnt': 'CYCLE_PNT',
						'estCnt': 'EST_CNT',
						'queneCnt': 'QUENE_CNT',
						'execCnt': 'EXEC_CNT',
						'successCnt': 'SUCCESS_CNT',
						'failedCnt': 'FAILED_CNT',
						'unknowCnt': 'UNKNOW_CNT',
						'waitCnt': 'WAIT_CNT',
						'currentCnt': 'CURRENT_CNT',
						'runState': 'RUN_STATE'
					},
					//排序方式映射
					sortTypes: {
						'descending': 'desc',
						'ascending': 'asc'
					},
					filterJobNm: '',
					filterJobNmOld: ''
				};
			},
			watch: {
				filterJobNm: function (val) {
					this.$refs.refTree.filter(val);
				}
			},
			mounted() {
				var _this = this;
				//测试
				_this.$nextTick(function () {
					var tableBox = _this.$refs.tableBox;
					let a = tableBox.getBoundingClientRect().top + 28;
					var theight = `calc(100vh - ${a}px - 370px)`;
					_this.tbHeight = theight;
				});

				yufp.frame.reloadTaskMonitorData = function () {
					_this.reloadData();
					_this.$refs.refTree.remoteData({});
				}
			},
			methods: {
				/*历史star*/
				showFlowChartHis: function (row) {
					var _this = this;

					// 判断是否已有页签id
					if (_this.customKey == '') {
						_this.customKey = 'custom_' + new Date().getTime();
						_this.routeId = 'router_' + new Date().getTime();
						var url = 'pages/use/monitors/taskMonitor/taskMonitorGraph/taskMonitorGraph';
						yufp.router.addRoute(_this.routeId, {
							html: url + '.html',
							js: url + '.js'
						});
					}

					// 获取当前页面是否有标签页
					var newtab = yufp.frame.getTab(_this.customKey);
					if (newtab == undefined) {//没有则使用routeId和customKey生成新的Tab
						yufp.frame.addTab({
							id: _this.routeId, // 菜单功能ID（路由ID）
							key: _this.customKey, // 自定义唯一页签key,请统一使用custom_前缀开头
							title: row.taskName + '_流程图', // 页签名称
							data: yufp.clone({ isHistory: true }, row)// 传递的业务数据，可选配置
						});
					} else {//有则删除原有tab页再生成
						//删除原有tab
						yufp.frame.removeTab(_this.customKey);
						//生成新的页签id
						_this.customKey = 'custom_' + new Date().getTime();
						//移除原有路由
						yufp.router.removeRoute(_this.routeId);
						//注册新的路由
						_this.routeId = 'router_' + new Date().getTime();
						var url = 'pages/use/monitors/taskMonitor/taskMonitorGraph/taskMonitorGraph';
						yufp.router.addRoute(_this.routeId, {
							html: url + '.html',
							js: url + '.js'
						});
						//生成新页签
						yufp.frame.addTab({
							id: _this.routeId, // 菜单功能ID（路由ID）
							key: _this.customKey, // 自定义唯一页签key,请统一使用custom_前缀开头
							title: row.taskName + '_流程图', // 页签名称
							data: yufp.clone({ isHistory: true }, row)// 传递的业务数据，可选配置
						});
					}
				},

				/* 					selectTask: function (selection) {
										var _this = this;
										if (selection[0] == null) {
											_this.rerunShow = false;
											_this.flowsheetShow = false;
										} else {
											_this.flowsheetShow = true;
											_this.rerunShow = true;
										}
									}, */
				/**
				 * 点击树的结点，加载对应的数据
				 */
				/* 					nodeClickFn: function (nodeData, node, self) {
										var _this = this;
										var taskId = "";
										var appCode = "";
										_this.currNodeData = nodeData;
								
										if (nodeData.nodeType === 'A') {
											appCode = nodeData.appCode;
											_this.isAppNode = true;
											_this.isNodeLeaf = false;
											_this.appNameDisabled = true;
											_this.$refs.wftRunForm.resetFields();
											_this.searchFormdata.appName = nodeData.currentNodeName;
											_this.taskNameDisabled = false
											//_this.searchFormdata.taskName = '';
								
										} else if (nodeData.nodeType === 'D') {
											appCode = nodeData.appCode;
											taskId = nodeData.currentNodeId;
											_this.isNodeLeaf = true;
											_this.isAppNode = false;
											_this.appNameDisabled = true;
											_this.$refs.wftRunForm.resetFields();
											_this.searchFormdata.appName = nodeData.parentName;
											_this.taskNameDisabled = true
											_this.searchFormdata.taskName = nodeData.currentNodeName;
										} else {
											_this.isNodeLeaf = false;
											_this.isAppNode = false;
											_this.appNameDisabled = false;
											_this.$refs.wftRunForm.resetFields();
											_this.searchFormdata.appName = '';
											_this.taskNameDisabled = false
											_this.searchFormdata.taskName = '';
										}
										_this.historyTaskLogTag = "historyTasksLog";
								
										_this.searchFormdata.appCode = appCode;
										_this.searchFormdata.taskId = taskId;
								
										var param = { condition: JSON.stringify(_this.searchFormdata) };
										_this.$refs.refTable.remoteData(param);
								
								
									}, */

				formartCycleDate: function (val) {
					if (val == null || val == '') {
						return "";
					}
					var d = new Date(val);
					var year = d.getFullYear();
					var month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1);
					var date = d.getDate() < 10 ? '0' + d.getDate() : d.getDate();

					return year + "" + month + "" + date;
				},

				queryTaskHisInfo: function (startDate, endDate) {
					var _this = this;
					var param = {
						appCode: _this.currNodeData.appCode, groupCode: _this.currNodeData.currentNodeId,
						queryStartDate: startDate, queryEndDate: endDate
					};
					yufp.service.request({
						url: backend.useService + '/monitor/taskMonitorHis/queryHisLineChart',
						method: 'get',
						data: param,
						callback: function (code, message, response) {
							if (response && response.data) {
								_this.$nextTick(function () {
									_this.initChart(response.data);
								});
							}
						}
					});
				},

				initChart: function (data) {
					var taskHisLineChart = echarts.init(document.getElementById("histaskLineChart"));
					taskHisLineChart.setOption(this.getLineOption(data));
				},

				showHisLineChart: function () {
					if (this.historyTaskLogTag === 'statisticTasksLog') {
						let startDate = "";
						let endDate = "";

						if (this.$refs.staticJobRef.fm.beginDate != null && this.$refs.staticJobRef.fm.beginDate != '') {
							startDate = this.formartCycleDate(this.$refs.staticJobRef.fm.beginDate);
						}

						if (this.$refs.staticJobRef.fm.endDate != null && this.$refs.staticJobRef.fm.endDate != '') {
							endDate = this.formartCycleDate(this.$refs.staticJobRef.fm.endDate);
						}

						this.queryTaskHisInfo(startDate, endDate);
					}
				},
				getLineOption: function (data) {
					return {
						title: {
							text: '任务名称:' + this.currNodeData.currentNodeName,
							x: 'center',
							y: 'top',
						},

						tooltip: {
							trigger: 'axis',
							formatter: '周期时点: {b}<br/> ' +
								'{a0}:{c0}秒'
						},

						xAxis: {
							type: 'category',
							boundaryGap: false,
							data: data.xAxisStrList,
							show: true,
							axisLabel: {
								show: true,
								interval: 'auto',
								formatter: '{value}'
							},
						},
						yAxis: {
							type: 'value',
							axisLabel: {
								show: true,
								interval: 'auto',
								formatter: '{value}秒'
							},
							// show: true
						},
						series: [

							{
								name: '平均耗时',
								type: 'line',
								smooth: true,
								data: data.datas,
							}
						]
					};
				},
				showTaskHis: function (row) {
					var customKey = 'custom_' + new Date().getTime();
					var routeId = 'router_' + new Date().getTime();
					var url = 'pages/use/monitors/taskMonitor/taskMonitorList/taskMonitorList';
					yufp.router.addRoute(routeId, {
						html: url + '.html',
						js: url + '.js'
					});
					row.customKey = customKey;
					row.isHistory = true;
					yufp.frame.addTab({
						id: routeId, // 菜单功能ID（路由ID）
						key: customKey, // 自定义唯一页签key,请统一使用custom_前缀开头
						// title: row.appName + '_流程图', // 页签名称
						title: '[' + row.taskName + ']历史作业清单', // 页签名称
						data: yufp.clone({ routeId: routeId, title: '[' + row.taskName + ']作业清单' }, row)// 传递的业务数据，可选配置
					});
				},
				/**
				 * 排序
				*/
				wftRunSortHis: function (column) {
					var _this = this
					_this.searchFormdataHis.sortColunm = _this.sortColunmsHis[column.prop];
					_this.searchFormdataHis.sorType = _this.sortTypesHis[column.order];
					var param = { condition: JSON.stringify(_this.searchFormdataHis) };
					_this.$refs.refTableHis.remoteData(param);
				},
				/*历史end*/
				saveCycleTime: function () {
					var _this = this;
					_this.$refs.refForm.validate(function (valid) {
						validate = valid;
					});
					if (!validate) {
						return;
					}
					var urlparam = "";
					if (_this.cycleOpr === 'selectCycle') {
						urlparam = "api/use/monitor/taskMonitor/saveSelectCycleTime";
					} else {
						urlparam = "api/use/monitor/taskMonitor/rollBackCycleTime";
					}

					_this.cycleLoading = true;
					yufp.service.request({
						method: 'POST',
						url: urlparam,
						data: _this.formdata,
						callback: function (code, message, response) {
							_this.cycleLoading = false;
							if (response.code == 0) {
								_this.reloadData();
								_this.$message('操作成功');
								_this.cycleTimeVisible = false;
							} else {
								_this.$message({ message: response.message, type: "warning" });
							}
						}
					});


				},
				cancelFn: function () {
					this.cycleTimeVisible = false;
				},

				selectCycleFn: function () {

					var _this = this;

					if (!_this.isNodeLeaf) {
						_this.$message({ message: "请选择一个任务", type: "warning" });
						return;
					} else {
						yufp.service.request({
							method: 'GET',
							url: "api/use/monitor/taskMonitor/selectInnerCycleTime",
							data: {
								appCode: _this.currNodeData.appCode,
								taskId: _this.currNodeData.currentNodeId
							},
							callback: function (code, message, response) {
								_this.cycleTitle = "任务指定运行"
								_this.cycleTimeVisible = true;
								_this.cycleOpr = "selectCycle";
								_this.cycleTimeLabel = '周期时点';
								_this.cycleTimeBtnLabel = '运行';
								_this.$nextTick(function () {
									_this.formdata.appCode = _this.currNodeData.appCode;
									_this.formdata.appName = _this.currNodeData.appName;
									_this.formdata.taskName = _this.currNodeData.currentNodeName;
									_this.formdata.groupCode = _this.currNodeData.currentNodeId;
									_this.formdata.cycleTime = response.data.cycleTime;
								});

							}
						});
					}
				},

				rollbackCycleFn: function () {

					var _this = this;

					if (!_this.isNodeLeaf) {
						_this.$message({ message: "请选择一个任务", type: "warning" });
						return;
					} else {
						yufp.service.request({
							method: 'GET',
							url: "api/use/monitor/taskMonitor/selectInnerCycleTime",
							data: {
								appCode: _this.currNodeData.appCode,
								taskId: _this.currNodeData.currentNodeId
							},
							callback: function (code, message, response) {
								if (response.code != 0) {
									_this.$message({ message: response.message, type: "warning" });
								} else {
									_this.cycleTimeVisible = true;
									_this.cycleTitle = "设置内置时点";
									_this.cycleOpr = "rollbackCycle";
									_this.cycleTimeLabel = '内置时点';
									_this.cycleTimeBtnLabel = '保存';
									_this.$nextTick(function () {
										_this.formdata.appCode = _this.currNodeData.appCode;
										_this.formdata.appName = _this.currNodeData.appName;
										_this.formdata.taskName = _this.currNodeData.currentNodeName;
										_this.formdata.groupCode = _this.currNodeData.currentNodeId;
										_this.formdata.cycleTime = response.data.cycleTime;
										_this.formdata.saveValue = response.data.saveValue !== ' '
											? response.data.saveValue : response.data.cycleTime;
									});

								}
							}
						});
					}

				},

				// 过滤作业树
				filterJob: function (value, data) {
					if (!value) {
						return true;
					}
					value = value.toUpperCase();
					return data.label.toUpperCase().indexOf(value) !== -1;
				},
				reloadData: function () {
					var _this = this
					var param = { condition: JSON.stringify(_this.searchFormdata) };
					_this.$refs.wftRunRefTable.remoteData(param);
				},
				getLocalTime: function (nS) {
					var date = new Date(nS);
					var year = date.getFullYear();
					var month = date.getMonth() + 1;
					var day = date.getDate();
					return year + month + day;
				},
				showFlowChart: function (row) {
					var _this = this;
					yufp.service.request({
						url: backend.useService + '/monitor/taskMonitor/queryFlowChart',
						method: 'get',
						data: {
							coreId: row.coreId,
							cycleNo: row.cycleNo,
							groupCode: row.groupCode,
							appCode: row.appCode
						},
						callback: function (code, message, response) {
							if (!response.data) {
								_this.$message({ message: '流程图数据为空！', type: 'warning', duration: 6000 });
								return;
							} else {
								var customKey = 'custom_' + new Date().getTime();
								var routeId = 'router_' + new Date().getTime();
								var url = 'pages/use/monitors/taskMonitor/taskMonitorGraph/taskMonitorGraph';
								yufp.router.addRoute(routeId, {
									html: url + '.html',
									js: url + '.js'
								});
								row.customKey = customKey;
								row.runFnButton = _this.runFnButton;
								yufp.frame.addTab({
									id: routeId, // 菜单功能ID（路由ID）
									key: customKey, // 自定义唯一页签key,请统一使用custom_前缀开头
									// title: row.appName + '_流程图', // 页签名称
									title: row.groupName, // 页签名称
									data: yufp.clone({ routeId: routeId }, row)// 传递的业务数据，可选配置
								});
							}
						}
					});
				},

				redoFlowChart: function (row) {
					var url = "api/use/monitor/taskMonitor/redoRunAllTask";
					this.commonRunTask(row, url);
				},

				interruptFlowChart: function (row) {
					var url = "api/use/monitor/taskMonitor/interruptAllTask";
					this.commonRunTask(row, url);
				},
				deleteFlowChart: function (row) {
					var url = "api/use/monitor/taskMonitor/deleteRunTask";
					this.commonRunTask(row, url);
				},

				rerunEvent: function () {
					var _this = this;
					if (_this.$refs.wftRunRefTable.selections.length !== 1) {
						_this.$message({ message: '请先选择一条记录', type: 'warning', duration: 6000 });
						return;
					}
					window.alert("重跑任务")
				},
				runTaskFn: function () {
					var _this = this;

					if (!_this.isNodeLeaf) {
						_this.$message("请选择一个任务");
						return;
					} else {
						_this.runTask("RUN", _this.currNodeData.appCode, _this.currNodeData.currentNodeId);
					}
				},
				debugTaskFn: function () {
					var _this = this;

					if (!_this.isNodeLeaf) {
						_this.$message("请选择一个任务");
						return;
					} else {
						_this.runTask("DEBUG", _this.currNodeData.appCode, _this.currNodeData.currentNodeId);
					}
				},
				selectIntervalFn: function (val) {
					var _this = this;
					if (val instanceof Object) {
						_this.refreshInterval = val.key
					} else {
						_this.refreshInterval = val
					}
				},
				refreshTable: function () {
					var _this = this;

					_this.setIntervalId = setInterval(fn, _this.refreshInterval);
					function fn() {
						clearInterval(_this.setIntervalId);
						// _this.$refs.refTable.remoteData("");
						_this.setIntervalId = setInterval(fn, _this.refreshInterval);
					}
				},
				selectTask: function (selection) {
					var _this = this;
					if (selection[0] == null) {
						_this.rerunShow = false;
						_this.flowsheetShow = false;
					} else {
						_this.flowsheetShow = true;
						_this.rerunShow = true;
					}
				},
				/**
				 * 点击树的结点，加载对应的数据
				 */
				nodeClickFn: function (nodeData, node, self) {
					var _this = this;
					var taskId = "";
					var appCode = "";
					_this.currNodeData = nodeData;

					if (nodeData.nodeType === 'A') {
						appCode = nodeData.appCode;
						_this.$refs.wftRunForm.resetFields();
						_this.$refs.wftRunFormHis.resetFields();
						_this.isAppNode = true;
						_this.isNodeLeaf = false;
						_this.appNameDisabled = true;
						_this.searchFormdata.appName = nodeData.appName;
						_this.searchFormdataHis.appName = nodeData.appName;
						_this.groupNameDisabled = false
						_this.placeholderTaskName = '';
					} else if (nodeData.nodeType === 'D') {
						appCode = nodeData.appCode;
						taskId = nodeData.currentNodeId;
						_this.$refs.wftRunForm.resetFields();
						_this.$refs.wftRunFormHis.resetFields();
						_this.isNodeLeaf = true;
						_this.isAppNode = false;
						_this.appNameDisabled = true;
						_this.searchFormdata.appName = nodeData.appName;
						_this.searchFormdataHis.appName = nodeData.appName;
						_this.groupNameDisabled = true;
						_this.searchFormdata.groupName = nodeData.realNodeName;
						_this.searchFormdataHis.groupName = nodeData.realNodeName;
					} else {
						_this.isNodeLeaf = false;
						_this.isAppNode = false;
						_this.appNameDisabled = false;
						_this.groupNameDisabled = false;
						_this.$refs.wftRunForm.resetFields();
						_this.$refs.wftRunFormHis.resetFields();
						//_this.placeholderTaskName = '系统名称';
						_this.placeholderTaskName = '任务名称';
					}
					_this.searchFormdata.appCode = appCode;
					_this.searchFormdata.taskId = taskId;
					_this.searchFormdataHis.appCode = appCode;
					_this.searchFormdataHis.taskId = taskId;
					if (_this.typeone == 'task') {
						var param = { condition: JSON.stringify(_this.searchFormdata) };
						_this.$refs.wftRunRefTable.remoteData(param);
						_this.reloadData();
					} else {
						_this.showHisLineChart();
						var param1 = { condition: JSON.stringify(_this.searchFormdataHis) };
						_this.$refs.refTableHis.remoteData(param1);
					}

				},

				runTask: function (runNode, appCode, taskId) {
					var _this = this;
					var url = "";
					if (runNode === 'DEBUG') {
						url = "api/use/monitor/taskMonitor/debugTask"
					} else {
						url = "api/use/monitor/taskMonitor/runTask"
					}
					var paramData = { appCode: appCode, currentNodeId: taskId };
					//运行任务时加载loading
					_this.loading = true;
					yufp.service.request({
						method: 'GET',
						url: url,
						data: paramData,
						callback: function (code, message, response) {
							//有返回时去掉loading
							_this.loading = false;
							if (response.code != 0) {
								_this.$message({ message: response.message, type: "warning" });
							} else {
								_this.$message("操作成功");
								_this.filterJobNmOld = _this.filterJobNm;//刷新前保存查找内容
								_this.$refs.refTree.remoteData({});
								//刷新后将值赋予搜索框
								_this.$nextTick(function () {
									_this.filterJobNm = _this.filterJobNmOld;
									_this.$refs.refTree.filter(_this.filterJobNmOld);
								})
								_this.reloadData();
							}

						}
					});

				},

				commonRunTask: function (row, url) {
					var _this = this;
					_this.loading = true;
					yufp.service.request({
						method: 'GET',
						url: url,
						data: row,
						callback: function (code, message, response) {
							_this.loading = false;
							if (response.code != 0) {
								_this.$message({ message: response.message, type: "warning" });
							} else {
								_this.$message("操作成功");
								_this.reloadData();
							}
						}
					});
				},
				/* 				formartCycleDate: function (val) {
									if (val == null) {
										return "";
									}
									var d = new Date(val);
									var year = d.getFullYear();
									var month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1);
									var date = d.getDate() < 10 ? '0' + d.getDate() : d.getDate();
				
									return year + "" + month + "" + date;
								}, */
				/**
				 * 排序
				*/
				wftRunSort: function (column) {
					var _this = this
					_this.searchFormdata.sortColunm = _this.sortColunms[column.prop];
					_this.searchFormdata.sorType = _this.sortTypes[column.order];
					var param = { condition: JSON.stringify(_this.searchFormdata) };
					_this.$refs.wftRunRefTable.remoteData(param);
				},
				showTask: function (row, jobState) {
					var customKey = 'custom_' + new Date().getTime();
					var routeId = 'router_' + new Date().getTime();
					var url = 'pages/use/monitors/taskMonitor/taskMonitorList/taskMonitorList';
					if (!(jobState instanceof Object)) {
						row.searchState = jobState;
					}
					row.redoBnt = !yufp.session.checkCtrl('redoBnt');
					row.interruptBnt = !yufp.session.checkCtrl('interruptBnt');
					row.forceSuccessBnt = !yufp.session.checkCtrl('forceSuccessBnt');
					row.preValueBnt = !yufp.session.checkCtrl('preValueBnt');
					row.unPreValueBnt = !yufp.session.checkCtrl('unPreValueBnt');
					row.forceJobValueBnt = !yufp.session.checkCtrl('forceJobValueBnt');
					row.jobParamBnt = !yufp.session.checkCtrl('jobParamBnt');
					row.jobPriorBnt = !yufp.session.checkCtrl('jobPriorBnt');
					yufp.router.addRoute(routeId, {
						html: url + '.html',
						js: url + '.js'
					});
					row.customKey = customKey;
					yufp.frame.addTab({
						id: routeId, // 菜单功能ID（路由ID）
						key: customKey, // 自定义唯一页签key,请统一使用custom_前缀开头
						// title: row.appName + '_流程图', // 页签名称
						title: '[' + row.groupName + ']作业清单', // 页签名称
						data: yufp.clone({ routeId: routeId, title: '[' + row.groupName + ']作业清单' }, row)// 传递的业务数据，可选配置
					});
				},
				renderHeader: function (h, { column, $index }) {
					var tips = ['', '', '', '', '', '','',
						'成功总数',
						'失败总数',
						'未知总数',
						'预估总数=当前任务包含的作业数',
						'当前总数=等待+队列+执行+成功+失败+未知',
						'等待总数',
						'队列总数',
						'执行总数',
					]
					return (
						h('span', [
							h('span', column.label + ' '),
							h('yu-tooltip', {
								props: {
									effect: 'light',
									content: tips[$index],
									placement: 'top'
								}
							}, [
									h('i', {
										class: 'el-icon-yx-question'
									})
								])
						])
					)
				},
				// 批量中断
				interruptFlowChartList: function () {
					var _this = this;
					var selections = _this.$refs.wftRunRefTable.selections;
					if (selections.length < 1) {
						_this.$message({ message: "请先选择一条数据", type: "warning" });
						return
					}
					for (var i in selections) {
						if (!(selections[i].runState === 'C' || selections[i].runState === 'R' || selections[i].runState === 'T')) {
							_this.$message({ message: "存在无法中断的任务,请重新选择", type: "warning" });
							return
						}
					}
					for (var i in selections) {
						_this.interruptFlowChart(selections[i]);
					}
				},
				// 批量续跑
				redoFlowChartList: function () {
					var _this = this;
					var selections = _this.$refs.wftRunRefTable.selections;
					if (selections.length < 1) {
						_this.$message({ message: "请先选择一条数据", type: "warning" });
						return
					}
					for (var i in selections) {
						if (!(selections[i].runState === 'I' || selections[i].runState === 'S') || (selections[i].runState === 'T' && selections[i].failedCnt != 0)) {
							_this.$message({ message: "存在无法续跑的任务,请重新选择", type: "warning" });
							return
						}
					}
					for (var i in selections) {
						_this.redoFlowChart(selections[i]);
					}
				},
				// 批量删除
				deleteFlowChartList: function () {
					var _this = this;
					var selections = _this.$refs.wftRunRefTable.selections;
					if (selections.length < 1) {
						_this.$message({ message: "请先选择一条数据", type: "warning" });
						return
					}
					for (var i in selections) {
						if (selections[i].runState !== 'N' && selections[i].runState !== 'I' && selections[i].runState !== 'S') {
							_this.$message({ message: "存在无法删除的任务,请重新选择", type: "warning" });
							return
						}
					}
					for (var i in selections) {
						_this.deleteFlowChart(selections[i]);
					}
				},
				// 跨系统事件生成
				generateEvent: function () {
					var _this = this;
					var selections = _this.$refs.wftRunRefTable.selections;
					if (selections.length != 1) {
						_this.$message({ message: "请先选择一条数据", type: "warning" });
						return
					}
					_this.loading = true;
					yufp.service.request({
						url: '/api/use/monitor/eventLog/generateEvent',
						method: 'get',
						data: {
							appCode: selections[0].appCode,
							groupCode: selections[0].groupCode,
							cycleTime: selections[0].cyclePnt
						},
						callback: function (code, message, response) {
							_this.loading = false;
							if (response.code == '0') {
								_this.$message({ message: "处理完成", type: "info" });
							} else {
								_this.$message({ message: response.message, type: "error" });
							}
						}
					});
				},
				tabClick: function () {
					var _this = this;
					if (_this.typeone == 'taskHis') {
						var param1 = { condition: JSON.stringify(_this.searchFormdataHis) };
						_this.$refs.refTableHis.remoteData(param1);
						_this.reloadData();
					} else {
						var param = { condition: JSON.stringify(_this.searchFormdata) };
						_this.$refs.wftRunRefTable.remoteData(param);
						_this.reloadData();
					}
				}
			},
		});
	};
});